fix(whatsapp): stop reconnect failing when the token lists several WABAs - #1094
fix(whatsapp): stop reconnect failing when the token lists several WABAs#1094viethung0o0 wants to merge 1 commit into
Conversation
|
Superseded by #1107, which landed the same fix through a stronger mechanism. Both changes start from the same finding: an embedded-signup token's Where they differ:
#1107 also removes the Rebasing this branch onto main would replace |
Summary
debug_tokenasgranular_scopes[whatsapp_business_management].target_ids[0]. A system-user token lists every WABA the business has shared with the app, and Meta does not keep that order stable between tokens, so the first entry only matched by luck.wabaIdagainst the whole list instead of the first entry.Changes
integrations/whatsapp/src/api/auth.ts:getSharedWabaId→getSharedWabaIds, returning every granted WABA id (the single-id helper had no remaining callers).apps/builder/src/features/integration-whatsapp/libs/waba-grant.ts:resolveGrantedWabaId/requireGrantedWabaIdwith aWABA_GRANT_FAILURESmap, shared by connect and reconnect so the selection rule lives in one place.actions/reconnect.action.ts: accepts the reconnect when the existing WABA is anywhere in the grant list; still rejects when the token does not cover it.actions/connect.action.ts:deriveSignupTargetstakes the requestedwabaIdand uses the same helper; the separate first-entry mismatch check is removed.whatsapp-waba-grant.test.ts(new), multi-WABA cases inwhatsapp-reconnect-action.test.ts,whatsapp-connect-action-registration.test.ts, andintegrations/whatsapp/__tests__/auth.test.ts.Test plan
pnpm lintpnpm --filter builder check-types && test(402 files / 2704 tests)pnpm --filter @chatbotx.io/integration-whatsapp check-types && test(24 files / 217 tests)